<template>
  <div v-if="show" class="fontDa">
    <div class="hzBox" v-if="cepingDjmxbList!=null&&cepingDjmxbList.length>0">
      <div class="kaohe-firsttitle">评价等次：</div>
      <div class="flex customRadioNewBox">
        <label :class="'flex footitem'" v-for="(d,i) in cepingDjmxbList" :key="i" :for="xpId+'_'+ i">
          <el-tooltip class="item" effect="dark" :disabled="d.dcZb==null" :content="d.dcName+'占比为'+d.dcZb+'%'" placement="top">
          <div>{{ d.dcName }}</div>
          </el-tooltip>
          <div class="cpTable">
              <el-button type="text" icon="el-icon-success" class="cpCheck" v-if="cepingDjmxb.dcId==d.id" ></el-button>
              <el-button type="text" class="cpCheck" v-else @click="djDaFen(d)"><i class="noChecked"></i></el-button>
            </div>
          <!-- <div class="customRadioNew">
            <input :id="xpId+'_'+ i" type="radio" :name="xpId+'_pjdj'" :value="d.id" @click="djDaFen(d)" :checked="cepingDjmxb.dcId==d.id">
            <label :for="xpId+'_'+ i"></label>
          </div> -->
        </label>
      </div>
    </div>
  </div>
</template>

<script>
import { xpInfoDc, daFenCp, daFenDj, queryBcpUserSzbg } from "@/api/ceping/cepinghdglxpxxb";

export default {
  name: "cpIndexHzDjdf",
  data() {
    return {
      show: false,
      df: true,
      cepingHdglXpxxb: {},
      cepingHdglb: {},
      cepingHdglXpxxDfjlbList: [],
      cepingHdglCppmxbInfo: {},
      cepingXmmxbList: [],
      cepingGzmxbList: [],
      cepingCpgzBcpmxb: {},
      cepingCpgzCpmxb: {},
      cepingCpgzCpmxCppzb: {},
      cepingDjmxbList: [],
      cepingCpgzBcpmxbUser: {},
      cepingCpgzBcpmxbDept: {},
      cepingXmmxbObj: {},
      fzbList: [],
      zbCj: 2,//指标层级
      tableColumn: [],
      tableHeader: [],
      tableData: [],//指标结构
      cepingDjmxb: {},
      ksdialogVisible: false,
      bgdialogVisible: false,
      bgUrl: "",
      list:[],
      dj:{}
    }
  },
  props: {
    xpId: {
      type: Number,
      default: 0
    },
    tabledata:[],
    djDfData:{
      goOn:false
    },
    cppId:""
  },
  watch:{
    djDfData:{
      handler(newVal){
        console.log("newVal:"+JSON.stringify(newVal))
        // if(newVal.goOn){
        //   this.goOn()
        // }
      },
      deep:true,
      immediate:true
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initXp(this.xpId)
    })
  },
  methods: {
    initXp(id) {
      this.show = false;
      this.df = true;
      xpInfoDc(id).then(res => {
        this.cepingHdglXpxxb = res.data.data.cepingHdglXpxxb;
        this.cepingHdglCppmxbInfo = res.data.data.cepingHdglCppmxbInfo;
        this.cepingHdglb = res.data.data.cepingHdglb;
        this.cepingHdglXpxxDfjlbList = res.data.data.cepingHdglXpxxDfjlbList;
        this.cepingDjmxbList = res.data.data.cepingDjmxbList;
        
        this.init();
      })
    }
    ,
    init() {
      this.cepingDjmxb = {};
      if (this.cepingHdglXpxxDfjlbList != null & this.cepingHdglXpxxDfjlbList.length > 0) {
        this.cepingHdglXpxxDfjlbList.forEach(r => {
          if (r.dfLx == 1) {
            this.cepingDjmxb = r;
            this.cepingDjmxbList.forEach(item=>{
              if(this.cepingDjmxb.dcId==item.id){
                  var obj={
                    xpId:this.cepingHdglXpxxb.id,
                    dcName:item.dcName,
                    dcZb:item.dcZb,
                    cppId:this.cppId
                  }
                  var params={
                    obj:obj,
                    type:"初始",
                  }
                  this.$emit('setList',params)
              }
            })
          }
        })
        this.show = true;
      } else {
        this.show = false;
      }
      
      
    }
    ,
    djDaFen(dj) {
      this.dj=dj
      var obj={
        xpId:this.cepingHdglXpxxb.id,
        dcName:dj.dcName,
        dcZb:dj.dcZb,
        cppId:this.tabledata[0].cppId
      }
      console.log(JSON.stringify(this.tabledata))
      var params={
        tabledata:this.tabledata,
        obj:obj,
        type:"修改",
      }
      this.$emit('setList',params)
      
    },
    goOn(){
      this.cepingHdglXpxxDfjlbList.forEach(r => {
        if (r.dfLx == 1) {
          let info = {
            xpCode: this.cepingHdglXpxxb.xpCode,
            cxpCode: this.cepingHdglXpxxb.cxpCode,
            xpId: this.cepingHdglXpxxb.id,
            dfId: r.id,
            dcId: this.dj.id,
            dcName: this.dj.dcName,
            dcFz: this.dj.dcFz
          }
          daFenDj(info).then(res => {
            if (res.data.code == "0") {
              this.cepingDjmxb = res.data.data.cepingHdglXpxxDfjlb;
              this.cepingHdglXpxxb = res.data.data.cepingHdglXpxxb;
            } else {
              this.$notify.closeAll();
              this.$notify.error(res.data.msg)
            }
          })
        }
      })
    },
  }
}
</script>

<style scoped>
</style>
